package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.jooq.tables.pojos.Address;
import com.example.demo.jooq.tables.pojos.Email;
import com.example.demo.model.request.AddressPageRequest;
import com.example.demo.model.request.AddressRequest;
import com.example.demo.model.request.VpsPageRequest;
import com.example.demo.model.response.AddressResponse;
import com.example.demo.service.order.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/address/")
public class AddressController {

    @Autowired
    private IAddressService iAddressService;
    @GetMapping(value = "list")
    public ResultObject<BasePageResponse<AddressResponse>> queryPageAddressList(AddressPageRequest addressPageRequest) {
        return iAddressService.queryPageAddressList(addressPageRequest);
    }

    /**
     * 地址保存
     * @param address 数据对象
     * @return
     */
    @PostMapping(value = "save")
    public ResultObject  saveAddress(@RequestBody AddressRequest address) {
        return iAddressService.saveAddress(address);
    }

    /**
     * 查询地址详情
     * @param addressId 数据对象
     * @return
     */
    @GetMapping(value = "detail")
    public ResultObject  queryAddressDetail(String addressId) {
        return iAddressService.queryAddressDetail(addressId);
    }

}
